from collections import Counter

def main():
    tokens = open("case1.txt").read().strip().split()

    it = iter(tokens)
    k = int(next(it))
    m = int(next(it))
    n = int(next(it))
    s = int(next(it))

    q = [float(next(it)) for _ in range(n)]

    X = []
    for _ in range(m):
        row = [float(next(it)) for __ in range(n + 1)]
        X.append(row[:n+1])

    dists = []
    for i in range(m):
        xi = X[i]
        dist2 = 0.0
        for j in range(n):
            diff = q[j] - xi[j]
            dist2 += diff * diff
        dists.append((i, dist2))

    dists.sort(key = lambda t: t[1])

    top_k_idx = [dists[i][0] for i in range(min(k, m))]
    top_k_labels = [X[i][n] for i in top_k_idx]

    cnt = Counter(top_k_labels)
    max_freq = max(cnt.values())

    tie_labels = {lab for lab, c in cnt.items() if c == max_freq}
    chosen = None
    for i in range(min(k,m)):
        lab = X[dists[i][0]][n]
        if lab in tie_labels:
            chosen = lab
            break

    print(chosen, cnt[chosen])

if __name__ == '__main__':
    main()
